package com.zyn.rsgl.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zyn.rsgl.mapper.SalaryAdjustmentMapper;
import com.zyn.rsgl.pojo.SalaryAdjustment;
import com.zyn.rsgl.service.SalaryAdjustmentService;
import com.zyn.rsgl.utils.commonResult.R;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SalaryAdjustmentServiceImpl extends ServiceImpl<SalaryAdjustmentMapper, SalaryAdjustment> implements SalaryAdjustmentService {
    @Override
    public R addAdjustment(SalaryAdjustment adjustment) {
        boolean saved = this.save(adjustment);
        if (saved) {
            return R.ok("调薪记录添加成功");
        }
        return R.fail("调薪记录添加失败");
    }

    @Override
    public R getAdjustmentsByUserId(String userId) {
        QueryWrapper<SalaryAdjustment> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id", userId);
        List<SalaryAdjustment> adjustments = this.list(queryWrapper);
        return R.ok(adjustments);
    }
}